<template>
	<view :style="[{paddingTop:CustomBar+'px'}]">
		<cu-custom bgColor="bg-colorP" :isBack="true" fatherCss="box-shadow:none">
			<block slot="backText"></block>
			<block slot="content">我的商户</block>
		</cu-custom>
		<view class="head bg-colorP">
			<view class="">
				<view class="text-price text-white">{{info.allmoney}}</view>
				<view class="">总提成(元)</view>
			</view>
			<view class="">
				<view class="text-price text-white">{{info.money}}</view>
				<view class="">当日提成(元)</view>
			</view>
		</view>
		<view class="weui-cell cont-slide">
			<view>日期：</view>
			<view class="weui-cell__bd text-blue">
				<picker mode="date" :value="date" start="2018-1-01" end="2999-12-31" @change="bindDateChange">
					<view class="picker">
						{{date}}
						<text class="lg text-colorP" :class="'cuIcon-right'"></text>
					</view>
				</picker>
			</view>
		</view>
		<view class="shop-list">
			<view class="shop-item" v-for="(item,index) in shopsList" :key="index">
				<view class="shop-tit">
					<image src="https://xarkbucket.oss-cn-hangzhou.aliyuncs.com/%E5%85%8D%E5%8D%95%E9%80%9AApp/my-shops.png" mode=""></image>
					<text class="text-cut">{{item.name}}</text>
				</view>
				<view class="shops-cont">
					<view class="">
						<view class="">订单金额</view>
						<view class="text-price text-colorP">{{item.shopmoney?item.shopmoney:'0'}}</view>
					</view>
					<view class="">
						<view class="">总提成</view>
						<view class="text-price text-colorP">{{item.tcmoney?item.tcmoney:'0'}}</view>
					</view>
					<view class="">
						<view class="">当日提成</view>
						<view class="text-price text-colorP">{{item.today_money?item.today_money:'0'}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				CustomBar: this.CustomBar,
				userInfo: '',
				info: '',
				date: '',
				shopsList: [],
				page: 1
			}
		},
		onLoad() {
			this.userInfo = uni.getStorageSync('userInfo')
			this.onBindCust()
			this.getShops()
		},
		onReachBottom() {
			this.getShops()
		},
		methods: {
			getShops() {
				var that = this;
				this.$request({
					url: '/Agents/getShopListNew',
					data: {
						page: that.page
					},
					success: res => {
						if (res.data.status == 1) {
							var shopsList = that.shopsList
							res.data.data.data.forEach(item => {
								shopsList.push(item)
							})
							that.shopsList = shopsList
							that.page++
							uni.hideLoading()
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			
			onBindCust() {
				var that = this;
				var date = new Date()
				date = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
				that.date = date
				this.$request({
					url: '/Agents/getagent',
					success: res => {
						if (res.data.status == 1) {
							that.info = res.data.data
							uni.hideLoading()
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},

			bindDateChange: function(e) {
				var that = this;
				that.date = e.detail.value
				this.$request({
					url: '/Agents/getagent',
					data: {
						date: e.detail.value
					},
					success: res => {
						if (res.data.status == 1) {
							that.info = res.data.data
							uni.hideLoading()
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
		}
	}
</script>


<style scoped>
	page {
		background: #f5f5f5;
	}
</style>
<style scoped>
	.head {
		height: 180rpx;
		width: 100%;
		display: flex;
		justify-content: space-between;
		padding: 24rpx 40rpx;
		box-sizing: border-box;
	}

	.head>view {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.head>view:nth-child(2)>view:nth-child(1) {
		text-align: right;
	}

	.head>view>view:nth-child(1) {
		color: #ffffff;
		font-size: 48rpx;
	}

	.head>view>view:nth-child(2) {
		color: #ffffff;
		font-size: 30rpx;
	}

	.weui-cell {
		padding: 30rpx 30rpx;
		overflow: hidden;
	}

	.cont-slide {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx;
		box-sizing: border-box;
		background: #fff;
	}

	.cont-slide .picker {
		text-align: right;
		color: #F34930;
		font-size: 26rpx;
	}

	.cont-slide .picker image {
		width: 30rpx;
		height: 25rpx;
	}

	.shop-list {
		width: 100%;
		padding: 20rpx 24rpx;
	}

	.shop-list .shop-item {
		padding: 20rpx;
		width: 100%;
		height: 210rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		border-radius: 8rpx;
		border: solid 1rpx #efefef;
		margin-bottom: 20rpx;
		background: #fff;
	}

	.shop-list .shop-item .shop-tit {
		display: flex;
		height: 60rpx;
		/* align-items: center; */
		width: 100%;
		border-bottom: solid 1rpx #efefef;
	}

	.shop-list .shop-item .shop-tit image {
		width: 32rpx;
		height: 28rpx;
		margin-right: 15rpx;;
	}
	
	.shop-list .shop-item .shop-tit text{
		font-size: 28rpx;
		line-height: 28rpx;
		color: #333;
		display: block;
		max-width: 450rpx;
	}

	.shop-list .shop-item .shops-cont {
		width: 100%;
		flex: 1;
		display: flex;
	}

	.shop-list .shop-item .shops-cont>view {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.shop-list .shop-item .shops-cont>view>view:nth-child(1) {
		font-size: 26rpx;
		color: #333333;
		margin-bottom: 10rpx;
	}

	.shop-list .shop-item .shops-cont>view>view:nth-child(1) {
		font-size: 24rpx;
		color: #333333;
	}
</style>
